package com.deyuanyun.pic.pipe.controller.vo;

import com.deyuanyun.pic.common.util.ObjectUtil;
import com.deyuanyun.pic.common.util.format.DateFormat;
import com.deyuanyun.pic.common.util.format.NumberFormat;
import com.deyuanyun.pic.pipe.domain.Valve;
import com.deyuanyun.pic.settings.support.biz.CodeUtil;
import com.deyuanyun.pic.settings.support.biz.PipeLineUtil;
import com.github.pagehelper.Page;

import java.util.ArrayList;
import java.util.List;

/**
 * 阀门信息
 */
public class ValveVO extends BaseVO<Valve> {

    // 管道名称
    private String pipeLineName;
    // 阀门编号(自定义编号)
    private String valvaNumber;
    // 阀门出厂编号(自定义编号)
    private String manufacturedNum;
    // 阀门状态
    private String valveStatus;
    // 阀门类型
    private String valveType;
    // 驱动类型
    private String operatorType;
    // 所属场站阀室
    private String pipeValveroomName;
    // 绝对距离(m)
    private String mileage;
    // 相对最近参考点
    private String reference;
    // 相对最近参考点距离(m)
    private String referenceDistance;
    // 是否自动阀
    private String automated;
    // 进口链接类型
    private String inletConnectionType;
    // 进口直径(mm)
    private String inletDiameter;
    // 进口壁厚(mm)
    private String inletWallThickness;
    // 出口连接类型
    private String outletConnectionType;
    // 出口直径(mm)
    private String outletDiameter;
    // 出口壁厚(mm)
    private String outletWallThickness;
    // 压力等级（MPa）
    private String pressureRating;
    // 阀门功能
    private String valvefunction;
    // 是否可远程控制
    private String indremotecon;
    // 修复建议
    private String repairSuggestiong;
    // 修复状态
    private String repairState;
    // 生产厂家
    private String manufacturer;
    // 生成日期
    private String manufacturedDate;
    // 投用日期
    private String inserviceDate;
    // 施工单位
    private String constructionCompany;
    // 监理单位
    private String inspectingCompany;
    // 检测单位
    private String testingCompany;
    // 链接计算结果表
    private String gisId;

    public String getPipeLineName() {
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getValvaNumber() {
        return valvaNumber;
    }

    public void setValvaNumber(String valvaNumber) {
        this.valvaNumber = valvaNumber;
    }

    public String getManufacturedNum() {
        return manufacturedNum;
    }

    public void setManufacturedNum(String manufacturedNum) {
        this.manufacturedNum = manufacturedNum;
    }

    public String getValveStatus() {
        return valveStatus;
    }

    public void setValveStatus(String valveStatus) {
        this.valveStatus = valveStatus;
    }

    public String getValveType() {
        return valveType;
    }

    public void setValveType(String valveType) {
        this.valveType = valveType;
    }

    public String getOperatorType() {
        return operatorType;
    }

    public void setOperatorType(String operatorType) {
        this.operatorType = operatorType;
    }

    public String getPipeValveroomName() {
        return pipeValveroomName;
    }

    public void setPipeValveroomName(String pipeValveroomName) {
        this.pipeValveroomName = pipeValveroomName;
    }

    public String getMileage() {
        return mileage;
    }

    public void setMileage(String mileage) {
        this.mileage = mileage;
    }

    public String getReference() {
        return reference;
    }

    public void setReference(String reference) {
        this.reference = reference;
    }

    public String getReferenceDistance() {
        return referenceDistance;
    }

    public void setReferenceDistance(String referenceDistance) {
        this.referenceDistance = referenceDistance;
    }

    public String getAutomated() {
        return automated;
    }

    public void setAutomated(String automated) {
        this.automated = automated;
    }

    public String getInletConnectionType() {
        return inletConnectionType;
    }

    public void setInletConnectionType(String inletConnectionType) {
        this.inletConnectionType = inletConnectionType;
    }

    public String getInletDiameter() {
        return inletDiameter;
    }

    public void setInletDiameter(String inletDiameter) {
        this.inletDiameter = inletDiameter;
    }

    public String getInletWallThickness() {
        return inletWallThickness;
    }

    public void setInletWallThickness(String inletWallThickness) {
        this.inletWallThickness = inletWallThickness;
    }

    public String getOutletConnectionType() {
        return outletConnectionType;
    }

    public void setOutletConnectionType(String outletConnectionType) {
        this.outletConnectionType = outletConnectionType;
    }

    public String getOutletDiameter() {
        return outletDiameter;
    }

    public void setOutletDiameter(String outletDiameter) {
        this.outletDiameter = outletDiameter;
    }

    public String getOutletWallThickness() {
        return outletWallThickness;
    }

    public void setOutletWallThickness(String outletWallThickness) {
        this.outletWallThickness = outletWallThickness;
    }

    public String getPressureRating() {
        return pressureRating;
    }

    public void setPressureRating(String pressureRating) {
        this.pressureRating = pressureRating;
    }

    public String getValvefunction() {
        return valvefunction;
    }

    public void setValvefunction(String valvefunction) {
        this.valvefunction = valvefunction;
    }

    public String getIndremotecon() {
        return indremotecon;
    }

    public void setIndremotecon(String indremotecon) {
        this.indremotecon = indremotecon;
    }

    public String getRepairSuggestiong() {
        return repairSuggestiong;
    }

    public void setRepairSuggestiong(String repairSuggestiong) {
        this.repairSuggestiong = repairSuggestiong;
    }

    public String getRepairState() {
        return repairState;
    }

    public void setRepairState(String repairState) {
        this.repairState = repairState;
    }

    public String getManufacturer() {
        return manufacturer;
    }

    public void setManufacturer(String manufacturer) {
        this.manufacturer = manufacturer;
    }

    public String getManufacturedDate() {
        return manufacturedDate;
    }

    public void setManufacturedDate(String manufacturedDate) {
        this.manufacturedDate = manufacturedDate;
    }

    public String getInserviceDate() {
        return inserviceDate;
    }

    public void setInserviceDate(String inserviceDate) {
        this.inserviceDate = inserviceDate;
    }

    public String getConstructionCompany() {
        return constructionCompany;
    }

    public void setConstructionCompany(String constructionCompany) {
        this.constructionCompany = constructionCompany;
    }

    public String getInspectingCompany() {
        return inspectingCompany;
    }

    public void setInspectingCompany(String inspectingCompany) {
        this.inspectingCompany = inspectingCompany;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public String getGisId() {
        return gisId;
    }

    public void setGisId(String gisId) {
        this.gisId = gisId;
    }

    public void fromDomain(Valve domain) {

        if (ObjectUtil.isEmptyAll(domain)) {
            return;
        }
        // 管道名称
        this.pipeLineName = PipeLineUtil.getPipeLineName(domain.getPipeLineId());
        // 阀门编号(自定义编号)
        this.valvaNumber = domain.getValvaNumber();
        // 阀门出厂编号(自定义编号)
        this.manufacturedNum = domain.getManufacturedNum();
        // 阀门状态
        this.valveStatus = CodeUtil.getName(domain.getValveStatus());
        // 阀门类型
        this.valveType = CodeUtil.getName(domain.getValveType());
        // 驱动类型
        this.operatorType = CodeUtil.getName(domain.getOperatorType());
        // 所属场站阀室
        this.pipeValveroomName = PipeLineUtil.getValveRoomName(domain.getPipeValveroomId());
        // 绝对距离(m)
        this.mileage = NumberFormat.format(domain.getMileage(), NumberFormat.FMT_PLACES3);
        // 相对最近参考点
        this.reference = domain.getReference();
        // 相对最近参考点距离(m)
        this.referenceDistance = NumberFormat.format(domain.getReferenceDistance(), NumberFormat.FMT_PLACES3);
        // 是否自动阀
        this.automated = convert(domain.getAutomated());
        // 进口链接类型
        this.inletConnectionType = CodeUtil.getName(domain.getInletConnectionType());
        // 进口直径(mm)
        this.inletDiameter = NumberFormat.format(domain.getInletDiameter());
        // 进口壁厚(mm)
        this.inletWallThickness = NumberFormat.format(domain.getInletWallThickness());
        // 出口连接类型
        this.outletConnectionType = CodeUtil.getName(domain.getOutletConnectionType());
        // 出口直径(mm)
        this.outletDiameter = NumberFormat.format(domain.getOutletDiameter());
        // 出口壁厚(mm)
        this.outletWallThickness = NumberFormat.format(domain.getOutletWallThickness());
        // 压力等级（MPa）
        this.pressureRating = NumberFormat.format(domain.getPressureRating());
        // 阀门功能
        this.valvefunction = CodeUtil.getName(domain.getValvefunction());
        // 是否可远程控制
        this.indremotecon = convert(domain.getIndremotecon());
        // 修复建议
        this.repairSuggestiong = CodeUtil.getName(domain.getRepairSuggestiong());
        // 修复状态
        this.repairState = CodeUtil.getName(domain.getRepairState());
        // 生产厂家
        this.manufacturer = domain.getManufacturer();
        // 生成日期
        this.manufacturedDate = DateFormat.format(domain.getManufacturedDate());
        // 投用日期
        this.inserviceDate = DateFormat.format(domain.getInserviceDate());
        // 施工单位
        this.constructionCompany = domain.getConstructionCompany();
        // 监理单位
        this.inspectingCompany = domain.getInspectingCompany();
        // 检测单位
        this.testingCompany = domain.getTestingCompany();
        // gis地址
        this.gisId = domain.getGisId();

        super.fromDomain(domain.getId(), domain.getRecorder(), domain.getRecordtime(), domain.getCreateRemark());
    }

    public Page<ValveVO> fromDomainList(Page<Valve> domainList) {
        Page<ValveVO> list = new Page<ValveVO>();
        for (Valve valve : domainList) {
            ValveVO valveVO = new ValveVO();
            valveVO.fromDomain(valve);
            list.add(valveVO);
        }
        BaseVOUtil.converterPage(domainList, list);
        return list;
    }

}